﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Diagnostics;
using CodeIn.Utils;
using CodeIn.Core;

namespace CodeIn.Ui.StatusBar {
	public partial class StatusBarView : UserControl {
		public StatusBarView() {
			InitializeComponent();
		}

		private void OnThemeSelectionChanged(object sender, SelectionChangedEventArgs e) {
			var cbox = sender as ComboBox;
			var item = cbox.SelectedItem;

			if (item == null)
				return;

			var theme = item.ToString();

			try {
				string themeUri = ResourceManager.Instance.Themes[theme].Uri;
				ResourceDictionary skin = new ResourceDictionary();
				skin.Source = new Uri(themeUri);
				Application.Current.Resources.MergedDictionaries.Clear();
				Application.Current.Resources.MergedDictionaries.Add(skin);
			} catch (IOException ex) {
				Debug.WriteLine(ex.Message);
			}
		}
	}
}
